using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.Design;

namespace Blader.UI.TextBox
{
    /// <summary>
    /// Summary description for AutoCompleteDictionary.
    /// </summary>
    [Serializable]
    public class AutoCompleteEntryCollection : List<IAutoCompleteEntry>
    {
        #region Nested type: AutoCompleteEntryCollectionEditor

        public class AutoCompleteEntryCollectionEditor : CollectionEditor
        {
            public AutoCompleteEntryCollectionEditor(Type type)
                : base(type)
            {
            }

            protected override bool CanSelectMultipleInstances()
            {
                return false;
            }

            protected override Type CreateCollectionItemType()
            {
                return typeof(AutoCompleteEntry);
            }
        }

        #endregion

        public List<IAutoCompleteEntry> Filter(string text)
        {
            return FindAll(a => a.IsMatch(text));
        }
    }
}